﻿using System;
using System.Collections.Generic;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Data;
using System.Text;
using ExtAspNet;
using System.IO;

namespace HY.WEB.SYS
{
    public partial class _databackup : PageBase
    {
        public string whe = "", stype = "";
        public string us;
        
        protected void Page_Load(object sender, EventArgs e)
        {
            us = Session["ID"].ToString();
            txtbak.Text= "~/data/";
        }

      
        //恢复数据
        protected void btrev_Click(object sender, EventArgs e)
        {
            string path = txtrev.Text;

            if (path == "")
            {
                Alert.Show("请输入备份路径");
                return;
            }

            if (checkfile(path))
            {
                if (BLL.Bllbackup.DataBackupConfigDB(Server.MapPath(path)))
                    Alert.Show("恢复成功!");
            }
            else
                Alert.Show("文件不存在!");


        }

        //备份数据
        protected void btbak_Click(object sender, EventArgs e)
        {
            string path = txtbak.Text;
           
            if (path == "")
            {
                Alert.Show("请输入备份路径");
                return;
            }

          checkdir(path);

          if (BLL.Bllbackup.DataBackupConfigDB(Server.MapPath(path)))
             Alert.Show("备份成功");

        }

        public void checkdir(string path)
        {
            
            if (Directory.Exists(Server.MapPath(path)) == false)//如果不存在就创建file文件夹
            {
                Directory.CreateDirectory(Server.MapPath(path));
            }
        }


      public   Boolean checkfile(string path)
        {
            if (File.Exists(Server.MapPath(path)))
              return true;
            else
                return false;

        }


    }
}
